﻿using System.Text;
using DatabaseGroup.SSIS.SourceAdapters.Parser;

namespace DatabaseGroup.UnitTests.SSIS.SourceAdapters.Parser
{
    /// <summary>
    /// Implements IParsingContext with dummy functionality for testing
    /// </summary>
    internal class ParsingContextTestImpl : IParsingContext
    {
        private IParsingState _currentState = null;
        private StringBuilder _currentText = new StringBuilder();

        /// <summary>
        /// Gets the current text value for the parsing context
        /// </summary>
        public string CurrentText
        {
            get { return _currentText.ToString(); }
        }

        /// <summary>
        /// Resets the current text to be zero size (empty)
        /// </summary>
        public void ResetText()
        {
            _currentText.Length = 0;
        }

        #region IParsingContext Members

        public IParsingState CurrentState
        {
            get { return _currentState; }
            set { _currentState = value; }
        }

        public void TransitionTo(IParsingState nextState)
        {
            _currentState = nextState;
        }

        public void Append(char ch)
        {
            _currentText.Append(ch);
        }

        public void Append(string text)
        {
            _currentText.Append(text);
        }

        #endregion
    }

}
